#!/usr/bin/env python2.7

# bender.py

import os, sys
#import re
#from datetime import datetime, timedelta
#from dateutil.parser import parse
import numpy as np
import matplotlib
matplotlib.use('Qt4Agg')
matplotlib.rcParams['backend.qt4']='PySide'
import matplotlib.pyplot as plt
from matplotlib.backends.backend_qt4agg import FigureCanvasQTAgg as FigureCanvas
from matplotlib.figure import Figure

#from mpl_toolkits.basemap import Basemap
#from matplotlib import mlab
#from netCDF4 import Dataset
from PySide.QtCore import *
from PySide.QtGui import *
from ui_datelist import *

class Datelist(QWidget, Ui_DatelistWidget):
    def __init__(self, parent=None, dtstrs=[]):
        super(Datelist, self).__init__(parent)
        self.setupUi(self)
        self.parent = parent
        if dtstrs:
            self.load(dtstrs)

    def load(self, dtstrs):
        self.datelist.clear()
        self.datelist.addItems(dtstrs)
        self.datelist.setCurrentRow(0)

    @property
    def index(self):
        return self.datelist.currentRow()

    @index.setter
    def index(self, i):
        self.datelist.setCurrentRow(int(i))

    @property
    def current_item(self):
        return self.datelist.currentItem()

if __name__ == '__main__':
    pass
